package com.mycompany.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;

@Entity
public class Regione extends AbstractEntity{
	

	private String name;
	
	@OneToMany(mappedBy="regione",fetch=FetchType.EAGER)
	private List<Provincia> provincie = new ArrayList<Provincia>() ;

	
	public Regione() {
		// TODO Auto-generated constructor stub
		name = "";
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<Provincia> getProvincie() {
		return provincie;
	}

	public void setProvincie(List<Provincia> provincie) {
		this.provincie = provincie;
	}
	
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return name;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		Regione other = (Regione) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
	
	


}
